package com.example.springboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springboot.entity.User;

/**
 * 雒鑫
 * Java Web
 */
/*@Mapper//注入到spring容器当中*/
public interface UserMapper extends BaseMapper<User> {





    /*@Insert("insert into `user` (username,password,name,phone,email,address,avatar,role)" +
            "values (#{username}, #{password}, #{name}, #{phone}, #{email}, #{address}, #{avatar},#{role})")
    void insert(User user);

    *//*
    根据id进行用户信息的修改
     *//*
    @Update("UPDATE `user` set  username=#{username}, password=#{password}, name=#{name},phone= #{phone}," +
            "email=#{email},address=#{address},avatar=#{avatar} where id=#{id}")
    void updataUser(User user);

    *//*
单个或多个删除用户
     *//*
    @Delete("delete from `user` where id=#{id}")
    void deleteUser(Integer id);

    *//*
    查询所有的用户
     *//*
    @Select("select *from `user` order by id desc ")
    List<User> selectAll();

    *//*
    根据id查询当前用户信息
     *//*
    @Select("select *from `user`where id=#{id} order by id desc")
    User selectById(Integer id);
    *//*
       根据姓名查询当前用户信息（返回多个数据）
        *//*
    @Select("select *from `user`where name=#{name} order by id desc")
    List<User> selectByname(String name);

    @Select("select *from `user`where username=#{username} and name=#{name} order by id desc")
        User SelectMore(@Param("username") String username, @Param("name") String name);
    *//*
    多条件语句查询时要加@Param注解
     *//*
    @Select("select *from `user`where username like concat('%', #{username},'%')  and name like concat('%' #{name},'%') order by id desc")
    List<User> SeletcByMo(@Param("username") String username, @Param("name") String name);
*//*
多条件模糊查询

//第一个查询当前页面需要显示的页数 以及显示多少个用户
//第二个查询 记录当前页面用户的总数
 *//*
   //1.
    @Select("select *from `user`where username like concat('%', #{username},'%')  and name like concat('%' #{name},'%') order by id desc limit #{skipNum}, #{pageSize}")
    List<User> SeletcByPage(@Param("skipNum") Integer skipNum, @Param("pageSize") Integer pageSize, @Param("username") String username, @Param("name") String name);
    //2.
    @Select("select count(id) from `user`where username like concat('%', #{username},'%')  and name like concat('%' #{name},'%') order by id desc ")
    int SeletcCountByPage(@Param("username") String username, @Param("name") String name);

    @Select("select *from `user`where username=#{username} order by id desc")
    User selectByUsername(String username);*/
}
